import $ from 'jquery'

export function sleep(t) {
    return new Promise(r => setTimeout(r, t));
}

export function rad(deg) {
    return deg * Math.PI / 180;
};

export function setStyle(node, styles) {
    Object.assign((node || {}).style || {}, styles);
}

export function audio(src) {
    const audio = new Audio(src);
    audio.oncanplay = function () {
        if (isFirtsFocus) audio.play();
    }
};

export let isFirtsFocus = false;
$(document)
    .on("focus", () => isFirtsFocus = true)
    .on("keydown", () => isFirtsFocus = true)
    .on("click", () => isFirtsFocus = true);